﻿using MediatR;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using WMS.API.Application.Command.BasicManagement;
using WMS.API.Application.Command.BasicManagement.ShelfManage;
using WMS.Domain.Entities.BasicManagement;
using WMS.ErrorCode;

namespace WMS.API.Controllers.BasicManagement
{
    /// <summary>
    /// 货架管理控制器
    /// </summary>
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class ShelfManageController : ControllerBase
    {
        /// <summary>
        /// 中介者
        /// </summary>
        private readonly IMediator _mediator;

        public ShelfManageController(IMediator mediator)
        {
            _mediator = mediator;
        }
        /// <summary>
        /// 货架管理仓储查询
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        /// <exception cref="NotImplementedException"></exception>
        [HttpGet]
        public async Task<APIResult<APIPaging<ShelfManageModel>>> ShelfManageModelQuery([FromQuery] ShelfManageModelCommand request)
        {
            var i = await _mediator.Send(request);
            return i;
        }
        /// <summary>
        /// 添加仓库信息命令处理
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<APIResult<int>> AddShelfManageModel(AddShelfManageModelCommand request)
        {
            var i = await _mediator.Send(request);
            return i;
        }
        /// <summary>
        /// 删除货架命令行
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpDelete]
        public async Task<APIResult<int>> DelShelfManageModel([FromQuery] DelShelfManageModelCommand request)
        {
            var i = await _mediator.Send(request);
            return i;
        }
        /// <summary>
        /// 修改货架信息
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpPut]
        public async Task<APIResult<int>> UpdShelfManageModel(UpdShelfManageModelCommand request)
        {
            var i = await _mediator.Send(request);
            return i;
        }

        /// <summary>
        /// 仓库下拉命令处理
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpGet]
        public Task<APIResult<IQueryable<WarehouseModel>>> WarehouseModelSelect([FromQuery]WarehouseModelCommand request)
        {
            var i = _mediator.Send(request);
            return i;
        }
    }
}
